"""


"""
from rest_framework.generics import ListAPIView, RetrieveAPIView, UpdateAPIView
from meiduo_admin.my_pagination import MyPageNumberPagination
from meiduo_admin.serializers.order_serialier import OrderSerializer, OrderDetailSerializer, OrderDetailStatusSerializer
from orders.models import OrderInfo


class OrderView(ListAPIView):
    serializer_class = OrderSerializer
    # queryset = OrderInfo.objects.all()
    pagination_class = MyPageNumberPagination

    def get_queryset(self):

        keyword = self.request.query_params.get("keyword")

        if keyword:
            return OrderInfo.objects.filter(order_id__contains=keyword)

        else:
            return OrderInfo.objects.all()


class OrderDetailView(RetrieveAPIView):
    serializer_class = OrderDetailSerializer
    queryset = OrderInfo.objects.all()


class OrderStatusView(UpdateAPIView):
    serializer_class = OrderDetailStatusSerializer
    queryset = OrderInfo.objects.all()
